# 文件打开open(name,mode,encoding),encoding=utf-8,mode:r,w,x
# 打开文件，open()获取了一个文件对象
f = open('111.txt', 'r', encoding='utf-8')
# 读取文件使用read()
print(f.read())


# 使用with open()as f:
with open('222.txt', 'r', encoding='utf-8') as ff:
    text = ff.read()
print(text)

# 使用绝对路径
fff = open(r'C:\Users\Administrator\Desktop\111.txt', encoding='utf-8')
print(fff.read())


fff = open('1112.txt', 'w', encoding='utf-8')
fff.write('11111')
fff.close()

date = '1234'
with open('77777.txt', 'a', encoding='utf-8')as f:
    f.write(date)


